package com.itheima.one;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

//获取单个客户端的信息的服务端
public class Server {
    public static void main(String[] args) {
        try {
            System.out.println("===服务端启动===");
            //1.定义一个ServerSocket对象进行端口注册
            ServerSocket ss=new ServerSocket(9999);
            //2.监听客户端的Socket链接请求
            Socket socket=ss.accept();
            //3.字节输入流读取
            InputStream is=socket.getInputStream();
            //4.缓冲字符输入流
            BufferedReader br=new BufferedReader(new InputStreamReader(is));
            String msg;
            while((msg=br.readLine())!=null){
                System.out.println("服务端接收到--"+msg);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
